<?php

class NewsCreateController extends BaseController
{
	
	public function actionIndex()
	{
		$model=new News;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['News']))
		{
			$model->attributes=$_POST['News'];
			//分类
			if($_POST['cateid3']>0){
				$model->znc_id = (int)$_POST['cateid3'];
			}elseif($_POST['cateid2']>0){
				$model->znc_id = (int)$_POST['cateid2'];
			}elseif($_POST['cateid1']>0){
				$model->znc_id = (int)$_POST['cateid1'];
			}else{
				//失败跳转
				$this->render('../index/error',array('message'=>'分类不能为空，请选择分类！'));
				exit;
			}
			if($model->save()){
				//成功跳转
				$this->render('../index/success',array(  
			            'message'=>'恭喜，信息发布成功',  
			            'links'=>array(  
			            		array('资讯管理页面',$this->pre_module_url.'/news/admin'),
 			                    array('继续发布信息',$this->pre_module_url.'/newsCreate/index'),  
			                    array('浏览发布的信息','/home/news/detail/id/'.$model->zne_id),  
			             ), 
				));
				exit;
			}
		}

		$this->render('index',array(
			'model'=>$model,
		));
	}

}